﻿//--------------------------------------------------------------------------------------------------------------
// <copyright file="CSPProceduresWUC.cs" company="Microsoft Corporation" author="David Martos" date="01/02/2008">
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// </copyright>
//--------------------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CSP.WebParts.UserControls
{
    /// <summary>
    /// Gets the list of all available cases
    /// </summary> 
    public class CSPProceduresWUC : CSPBaseWUC
    {
        #region Properties
        public string DataSource { get; set; }
        #endregion

        #region Members
        protected System.Web.UI.WebControls.Repeater ProceduresRepeater;
        #endregion

        #region Methods
        /// <summary>
        /// Fired on page prerender
        /// </summary> 
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            try
            {
                if (!IsPostBack)
                {
                    System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument();
                    xdoc.LoadXml(DataSource);

                    System.Data.DataSet ds = new System.Data.DataSet();
                    ds.ReadXml(new System.Xml.XmlNodeReader(xdoc));
                    ProceduresRepeater.DataSource = ds;
                    ProceduresRepeater.DataBind();
                }
            }
            catch (CSP.Core.CSPException cspex)
            {
                throw cspex;
            }
            catch (Exception ex)
            {
                this.LogMessage(this.LoadResource(WebPartConstants.CSPProceduresLoadErrorMessage), this.GetType().Name, ex);
                throw ex;
            }
        }
        #endregion
    }
}
